﻿
/**
*@description 法务回复表单
*/
Chenxin.UI.LawToReplyForm=Chenxin.extend(Chenxin.UI.FormCommon,{	
	actionUrl:'/service/logic/ShowListArchive.ashx',
	id:'lawtoreply',
	renderTo:'lawtoreplyWin',
	jqmWidth:650,
	createForm:function(){
		return Chenxin.FormCommon.LawToReplyForm(this.id);
	},
	afterGetFormJson:function(){
	    if (this.filename != undefined) {
            this.additionalParam.filename = this.filename;
            this.additionalParam.savename = this.savename;
	    }
	},
    initEvent: function() {
		var _this=this;
		var thisid='#'+this.id;	
//		_this.isclick = true;

		var isComplete = true;
		var hasFile = false;
		
		$(thisid+'_save').live('click',function(){		
		    $("#LawToFile").uploadifyUpload();
//		    if(_this.isclick)
            if (isComplete && !hasFile) {
			    _this.save();
			}
		});
		$(thisid+'_cancle').live('click',function(){			
			_this.hide();
		});

        //上传附件Flash
        $("#LawToFile").uploadify({
            uploader: '/js/Plug/uploadify.swf',
            script: '/service/logic/ShowListArchive.ashx?op=fileupload',
            cancelImg: '/images/cancel.png',
            buttonImg:'/images/fileupload.png', 
            auto: false,
            multi: false,
            sizeLimit: 1048576,
            height: 24,
            width: 190,
            fileDesc: '支持格式:xls,doc,pdf,rar,zip,jpg,xlsx,docx',  
            fileExt: '*.xls;*.doc;*.pdf;*.rar;*.zip;*.jpg;*.xlsx;*.docx',
            wmode:'transparent',
            onSelect: function(event, queueID, fileObj) {
                hasFile = true;
            },
            onClick: function(){
//                _this.isclick = false;
                if (!hasFile) {
                    isComplete = false;
                }
            },
            onSelectCancel: function(){
                //_this.isclick = true;
                if (!hasFile) {
                    isComplete = true;
                } 
            },
            onComplete: function(event, queueID, fileObj, response, data) {
                if(response){
					try{					
						eval("var json="+response);
						if(json.success==1){
							if(data.fileCount==0){
							    _this.filename = json.data.filename;
                                _this.savename = json.data.savename;
							    _this.save();
//							    _this.isclick = true;
							     isComplete = true;
                                 hasFile = false;
                                 delete _this.filename;
                                 delete _this.savename;
							} 
						}else if(json.success==0){
							alert(json.msg);
						}else{
							alert(json.msg);
							window.location.href=Chenxin.loginUrl;
			            }
			       	}catch(e){
						alert('返回数据格式错误，文件上传失败！');
					}
				}
            },
            onError: function(event, queueID, fileObj, errorObj) {
                alert("文件:" + fileObj.name + "上传失败("+errorObj.info+")");
            },
            onCancel: function(event, queueID, fileObj) {
//                _this.isclick = true;
                isComplete = true;
                hasFile = false;
            }
        });

    },
	initComponent:function(){
		Chenxin.UI.LawToReplyForm.superclass.initComponent.call(this);
	}
});


Chenxin.FormCommon.LawToReplyForm=function(formID){
return '<table class="tbl_f"><tr><th style="width:105px; height:26px;">报备部门：</th><td><input name="DepartName" class="inputbox_n fl" type="text" readonly style="width:150px;"/></td></tr><tr><th>报备人：</th><td><input name="Employee" class="inputbox_n fl" type="text" readonly style="width:150px;"/></td></tr><tr><th>房源编号：</th><td><input name="HouseCode" class="inputbox_n fl" type="text" readonly style="width:150px;"/></td></tr><tr><th>房源地址：</th><td><input name="HouseAddress" class="inputbox_n fl" type="text" readonly style="width:150px;"/></td></tr><tr id="tr_law"><th>法务回复描述：</th><td><textarea name="LawAnswerContent" cols="80" rows="10" class="textarea_n" style=" float:left; width: 470px; height: 100px; padding:5px;"></textarea></td></tr><tr id="tr_applydoc"><th>办证回复描述：</th><td><textarea name="ApplyDocAnswerContent" cols="80" rows="10" class="textarea_n" style=" float:left; width: 470px; height: 100px; padding:5px;"></textarea></td></tr><tr><th>附件：</th><td><input type="file" name="LawToFile" id="LawToFile" /></td></tr><tr><td colspan="2"><input type="hidden"  name="RecordId" /><div style="float:right; margin-right:44px; margin-top:5px;"><a id="' + formID + '_save" class="btn_n fl" href="javascript:void(0);"><span>确定</span></a><a id="' + formID + '_cancle"  class="btn_n fl" href="javascript:void(0);"><span>取消</span></a></div></td></tr></table>';
};